package com.tiancheng.onecode.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiancheng.onecode.model.response.PageInfo;

public interface MYBaseMapper<T> extends BaseMapper<T> {

    /**
     * 分页查询
     *
     * @param var2  {@link Wrapper<T>}
     * @param page  页码
     * @param limit 每页条数
     * @return {@link PageInfo<T>}
     */
    default PageInfo<T> find(Wrapper<T> var2, int page, int limit) {
        IPage<T> pageResult = this.selectPage(new Page<>(page, limit), var2);
        return new PageInfo<>(pageResult.getCurrent(),pageResult.getSize(),pageResult.getTotal(),pageResult.getRecords());
    }
}
